﻿using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Psi.Core.Enums;
//using Psi.Core.Infrastructure;

namespace Psi.Core.Models
{
    /// <summary>
    /// 产品表
    /// </summary>
    [Table("Product")]
    public class Product : Entity
    {
        public Product()
        {
            var dt = DateTime.Now;
            Status = 1;
            Hits = 0;
            //Sort = DateHelper.DateTimeToStamp(dt);
            AddTime = dt;
            LastTime = dt;
        }
        /// <summary>
        /// 标题
        /// </summary>
        [Display(Name = "标题")]
        [Required(ErrorMessage = "*必填")]
        [StringLength(255, ErrorMessage = "必须少于{0}个字")]
        public string Title { get; set; }
        /// <summary>
        /// 副标题
        /// </summary>
        public string Text { get; set; }
        /// <summary>
        /// 内容
        /// </summary>
        [Display(Name = "内容")]
        [DataType(DataType.Html)]
        public string Content { get; set; }
        [Display(Name = "属性")]
        [DataType(DataType.Html)]
        public string Attr { get; set; }
        /// <summary>
        /// 链接
        /// </summary>
        [Display(Name = "链接")]
        [StringLength(255, ErrorMessage = "必须少于{0}个字符")]
        public string Url { get; set; }
        /// <summary>
        /// 缩略图
        /// <remarks>图片至少上传1张（第一张不计图片空间容量），图片类型只能为gif,png,jpg,jpeg，且大小不超过500K</remarks>
        /// </summary>
        [Display(Name = "缩略图")]
        [StringLength(255, ErrorMessage = "必须少于{0}个字符")]
        public string Image { get; set; }
      
        [Display(Name = "原价")]
        [Column(TypeName = "decimal(65, 2)")]
        public decimal Price { get; set; }
        [Display(Name = "促销价")]
        [Column(TypeName = "decimal(65, 2)")]
        public decimal Promo { get; set; }
        [Display(Name = "库存")]
        public int Stock { get; set; }
        [Display(Name = "货号")]
        public string SN { get; set; }
        ///// <summary>
        ///// 录入者
        ///// </summary>
        //[MaxLength(20)]
        //[Display(Name = "录入者")]
        //public int Inputer { get; set; }
        /// <summary>
        /// 分类Id
        /// </summary>
        public int CatId { get; set; }
        /// <summary>
        /// 点击量
        /// </summary>
        [Display(Name = "点击量")]
        public int Hits { get; set; }
        /// <summary>
        /// 关键字
        /// </summary>
        [MaxLength(512)]
        [Display(Name = "关键字")]
        public string Keywords { get; set; }
        /// <summary>
        /// 摘要
        /// </summary>
        [Display(Name = "摘要")]
        [StringLength(255, ErrorMessage = "必填少于{0}个字")]
        public string Description { get; set; }
        /// <summary>
        /// 状态
        /// <remarks>删除-2 关闭-1 审核/草稿0 发布1</remarks>
        /// </summary>
        [Display(Name = "状态")]
        public int Status { get; set; }
        /// <summary>
        /// 排序 
        /// <remarks>默认0 越大越靠前</remarks>
        /// </summary>
        [Display(Name = "排序")]
        public int Sort { get; set; }
        /// <summary>
        /// 发布日期
        /// </summary>
        [Display(Name = "发布日期")]
        public DateTime AddTime { get; set; }
        public DateTime LastTime { get; set; }
        public virtual Category Category { get; set; }
    }
}
